﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="Carroit.Web.admin.login" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>

<!DOCTYPE html>
<%="<!--[if IE 8]> <html class=\"ie8 no-js\"> <![endif]-->"%>
<%="<!--[if IE 9]> <html class=\"ie9 no-js\"> <![endif]-->"%>
<%="<!--[if !IE]><!-->"%>
<html>
<%="<!--<![endif]-->"%>
<!-- BEGIN HEAD -->

<head>
    <meta charset="utf-8" />
    <title>管理员登录 - <%=Evan.Common.CommFun.GetAppSetting("AdminTitle") %></title>
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <meta content="Smarta.CMS , 管理员登录" name="description" />
    <meta content="Smarta.CMS" name="author" />
    <!-- #include file="include/com_res_css.inc" -->
    <style type="text/css">
        html, body {
            height: 100%;
            overflow: hidden;
        }

        canvas {
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            pointer-events: none;
        }
    </style>
</head>

<!-- END HEAD -->

<body class=" login">
    <!-- BEGIN LOGO -->
   <%-- <div class="logo">
        <a>
            <img src="assets/pages/img/logo.png" alt="" style="max-width: 150px;" />
        </a>
    </div>--%>
    <!-- END LOGO -->
    <!-- BEGIN LOGIN -->
    <div class="content" style="padding-bottom: 10px;">
        <!-- BEGIN LOGIN FORM -->
        <form class="login-form">
            
            <div class="form-group">
                <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
                <label class="control-label visible-ie8 visible-ie9">账号</label>
                <input class="form-control form-control-solid placeholder-no-fix" type="text" id="username" autocomplete="off" placeholder="请输入账号" name="username" />
            </div>
            <div class="form-group">
                <label class="control-label visible-ie8 visible-ie9">密码</label>
                <input class="form-control form-control-solid placeholder-no-fix" type="password" id="password" autocomplete="off" placeholder="请输入密码" name="password" />
            </div>

            <div class="form-group <%=Evan.Common.CommFun.GetAppSetting("AdminIsVcode") != "1" ? "hide" : "" %>">
                <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
                <label class="control-label visible-ie8 visible-ie9">验证码</label>
                <div class="input-group" style="width: 100%;">
                    <input class="form-control form-control-solid placeholder-no-fix" type="text" id="vcode" autocomplete="off" placeholder="请输入验证码" name="vcode" value="<%=Evan.Common.CommFun.GetAppSetting("AdminIsVcode") != "1" ? "0000" : "" %>" />
                    <span class="input-group-addon" style="padding: 0; border: none;">
                        <img class="verifyCode_Img" title="点击刷新验证码 , 有效期3分钟 , 不区分大小写" src=""
                            _src="/ashx/CheckCode.ashx?bgcolor=dde3ec&name=adminlogin&color=gray&size=18&offset=6" style="width: 100px; height: 43px;" />
                    </span>
                </div>
            </div>
            <div class="form-group">
                <label class="rememberme check mt-checkbox mt-checkbox-outline no_margin_left margin_top_10">
                    <input type="checkbox" name="remember" id="remember" value="1" />记住账号
                        <span></span>
                </label>
                <% if (Request.Browser.Browser.ToLower() == "IE".ToLower() || Request.Browser.Browser.ToLower() == "InternetExplorer".ToLower())
                    { %>
                <label class="control-label" style="font-size: 14px; float: right; display: inline-block; color: #8290a3;"><i class="fa fa-exclamation-circle tooltips" style="font-size: 14px;" data-original-title="为了获得良好的功能体验，建议您使用谷歌浏览器。"></i>建议使用谷歌浏览器进行操作</label>
                <% } %>
                <%--<a href="javascript:;" id="forget-password" class="forget-password hide" style="margin-top:0px;">忘记密码 ?</a>--%>
            </div>
            <div class="form-actions">
                <button type="button" id="btn_login" data-loading-text="登录中.." class="btn green btn-block">登录</button>
            </div>
        </form>
        <!-- END LOGIN FORM -->
        <%--<!-- BEGIN FORGOT PASSWORD FORM -->
            <form class="forget-form">
                <h3 class="font-green">找回密码</h3>
                <p>请输入您的邮箱账号 , 您会收到一封邮件</p>
                <div class="form-group">
                    <input class="form-control placeholder-no-fix" type="text" id="email" autocomplete="off" placeholder="请输入您的邮箱账号" name="email" /> </div>
                <div class="form-actions">
                    <button type="button" id="back-btn" class="btn green btn-outline pull-left" style="float:left !important;">返回</button>
                    <button type="button" id="btn_findpwd" class="btn btn-success uppercase pull-right" style="float:right !important;">确定</button>
                </div>
            </form>
            <!-- END FORGOT PASSWORD FORM -->--%>
        <div class="copyright" style="margin: 10px 0 0 0;">2003-<%=DateTime.Now.Year %> © 沙漠风</div>
    </div>
    <div style="position: absolute; bottom: 0px; height: 18px; color: white; font-size: 12px; right: 10px;">图片来自免费图库 pixabay.com</div>
    <!--[if lt IE 9]>
            <script src="assets/global/plugins/respond.min.js"></script>
            <script src="assets/global/plugins/excanvas.min.js"></script> 
        <![endif]-->
    <!-- BEGIN CORE PLUGINS -->
    <script src="assets/global/plugins/jquery.min.js" type="text/javascript"></script>
    <script src="assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="assets/global/plugins/js.cookie.min.js" type="text/javascript"></script>
    <script src="assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
    <script src="assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
    <script src="assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>

    <!-- BEGIN THEME GLOBAL SCRIPTS -->
    <script src="assets/global/scripts/app.min.js" type="text/javascript"></script>
    <!-- END THEME GLOBAL SCRIPTS -->
    <!-- BEGIN PAGE LEVEL SCRIPTS -->

    <!-- #include file="include/com_res_js.inc" -->

    <script type="text/javascript">
        var csrf_token = "<%=Evan.Common.CommFun.TokenGenerate(false)%>";
        function ChangeCode() {
            var src = $(".verifyCode_Img").attr("_src");
            $(".verifyCode_Img").attr("src", src + ((src.indexOf('?') > -1) ? "&" : "?") + "t=" + Math.random());
        }
        $(function () {

            var RememberAdminAccount = $.Cookie_Get("AdminAccount");
            if (RememberAdminAccount !== null) {
                $("#username").val(RememberAdminAccount);
                $("#remember").prop("checked", "checked");
            }

            $("input").keydown(function (event) {
                event = document.all ? window.event : event;
                if ((event.keyCode || event.which) == 13) {
                    $("#btn_login").click();
                }
            });

            var adminlogin_flag = false;
            $("#btn_login").on("click", function () {
                if (adminlogin_flag) {
                    return false;
                }
                var username = $("#username").val();
                var password = $("#password").val();
                var vcode = $("#vcode").val();
                var isRemember = $("#remember").is(':checked');
                if (username == "") {
                    notice("请填写您的管理账号", "warning");
                    return false;
                }
                if (password == "") {
                    notice("请填写您的管理密码", "warning");
                    return false;
                }
                if (vcode == "" || vcode.length != 4) {
                    notice("请输入验证码", "warning");
                    return false;
                }
                password = rsa.Encrypt(password);
                $('#btn_login').button('loading');

                var a = { name: username, pwd: password, code: vcode, token: csrf_token };
                adminlogin_flag = true;
                AjaxSubmit(appConfig.adminPath + "ashx/administrator.ashx", "adminLogin", a, function (flag, data) {
                    if (flag) {
                        if (parseInt(data.result) == 1) {
                            $('#btn_login').text("登录成功 , 正在跳转...");
                            if (isRemember) {
                                $.Cookie_Set("AdminAccount", username, "d30");
                            }
                            var from_url = QueryString.GetValue("from");
                            if (from_url != "" && from_url !== undefined) {
                                window.location.href = decodeURIComponent(from_url);
                            }
                            else {
                                window.location.href = appConfig.adminPath + "index.aspx";
                            }
                        }
                        else {
                            adminlogin_flag = false;
                            $('#btn_login').button('reset');
                            notice(data.returnval, "error");
                            ChangeCode();
                        }
                    }
                    else {
                        adminlogin_flag = false;
                        $('#btn_login').button('reset');
                        notice("登录出错 , 请稍后再试", "error");
                        ChangeCode();
                    }
                    //console.log(flag, data);
                });
                //$('#btn_login').button('reset');
                //window.location.href = "index.aspx";
            });

            //忘记密码面板的确认按钮
            $("#btn_findpwd").on("click", function () {
                var email = $("#email").val();
                if (email == "") {
                    notice("请填写您的邮箱账号", "warning");
                    return false;
                }
                notice("新密码已经发送到您的邮箱 , 请注意查收", "success");
            });

            //忘记密码按钮
            $('#forget-password').click(function () {
                $('.login-form').fadeOut(200, function () {
                    $('.forget-form').fadeIn(200);
                });
            });
            //忘记密码的返回
            $('#back-btn').click(function () {
                $('.forget-form').fadeOut(200, function () {
                    $('.login-form').fadeIn(200);
                });
            });
        });

    </script>

    <%--<% if (Request.Url.Host == "localhost" || Request.Url.Host.EndsWith("kaola.ws", StringComparison.OrdinalIgnoreCase)) { %>--%>
    <script src="assets/global/plugins/backstretch/jquery.backstretch.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $.backstretch(["assets/custom/img/login_bg_01.jpg", "assets/custom/img/login_bg_02.jpg", "assets/custom/img/login_bg_03.jpg", "assets/custom/img/login_bg_04.jpg", "assets/custom/img/login_bg_05.jpg"],
                {
                    fade: 1000,
                    duration: 8000
                });
        })
    </script>
    <%--<%} %>--%>
</body>

</html>
